package spring.AOPDemo.BeforeAdviceTest;


import org.springframework.aop.ThrowsAdvice;

import java.lang.reflect.Method;

public class ExceptionAdvice implements  ThrowsAdvice{
    //自己定义方法，名字必须是afterThrowing，前三个入参要么都提供，要么不提供
    public void afterThrowing(Method method, Object[] args, Object target, Exception ex) throws Throwable {
        System.out.println("------------");
        System.out.println("method: " + method.getName());
        System.out.println("抛出异常：" + ex.getMessage());
        System.out.println("成功回滚事务");
    }
}
